using System;
using System.IO;
using System.Resources;
using System.Collections;

namespace App
{
    public class Resource
    {

        public static object Load(string filename)
        {
            ResourceReader rr = new ResourceReader(filename);
            IDictionaryEnumerator de = rr.GetEnumerator();
            object m = null;
            while (de.MoveNext())
            {
                if (de.Key != null)
                {
                    m = de.Value;
                }
            }
            rr.Close();
            return m;
        }

        public static string Save(string filename, object obj, string type)
        {
            try
            {
                ResourceWriter rw = new ResourceWriter(filename);
                rw.AddResource(type, obj);
                rw.Close();
                return null;
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }
    }

}
